namespace Webbness.Generator.CodeDom.Sql

import System
import System.Text
import Neo.Generator.Core
import Neo.MetaModel

enum ActionType:
	ADD
	ALTER
	DROP
	NONE

class DatabaseModelContext(GenerationContext):
	
	_tables as List
	
	def constructor(model as Model):
		super(model)
		_tables = List()
		
	def AddTable(table as SqlTable):
		if not _tables.Contains({e as SqlTable | return e.TableName.Equals(table.TableName, StringComparison.InvariantCultureIgnoreCase)} ):
			_tables.Add(table)
	
	def GetTable(tableName as string) as SqlTable:
		for table in Tables:
			if table.TableName.Equals(tableName, StringComparison.InvariantCultureIgnoreCase):
				return table
		return null
		
	def TableIsInModel(tableName as string) as bool:
		return _tables.Contains({e as SqlTable | return e.TableName.Equals(tableName, StringComparison.InvariantCultureIgnoreCase)} )
	
	Tables as (SqlTable):
		get:
			return _tables.ToArray(typeof(SqlTable))
			
	[property(ProjectName)]
	_projName as string
	
	[property(ProjectType)]
	_projType as string
		
	[property(BaseDirectory)]
	_baseDir as string
	
	[property(Extension)]
	_extension as string
	
	[property(Version)]
	_version as string
	
	[property(GenAdmin)]
	_genAdmin as bool
	
	[property(UseBuiltins)]
	_useBuiltins as bool

	public override def ToString() as string:
		return "DatabaseModelContext"
